package com.jessechanrui.template.example;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author chenrui
 * @version 1.0
 * @description PdfWriterExample
 * @date 2025/10/9
 */
public class PdfWriterExample {
    public static void main(String[] args) throws DocumentException, IOException {
        Document document = new Document(PageSize.LETTER, 50, 50, 50, 50);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("F:\\configured_document.pdf"));
        // 设置文档属性
        document.addAuthor("iText Developer");
        document.addTitle("Sample PDF Document");
        document.addSubject("PDF Generation using iText");
        document.addKeywords("iText, PDF, Java");

        // 启用压缩
        writer.setFullCompression();


        document.open();
        // 添加内容（此处省略）

        document.close();
    }
}
